package com.zzl.scala

import org.apache.spark.{SparkConf, SparkContext}

object AccumulatorTest {

  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf()
      .setAppName("CacheTest")
      .setMaster("local")
    val sc = new SparkContext(sparkConf)
 var count=0
    val rdd = sc.textFile("sp")
    val accmulator = sc.accumulator(0)
    val rdd1 = rdd.map(
      x=>{
        accmulator.add(1)
        count +=1
        x
      }
    )
    rdd1.collect()
    println(accmulator.value+"=8888888")
    println(count+"=999999999999")
  }
}
